package com.rockxin.cat.adapter;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.rockxin.cat.R;
import com.rockxin.cat.bean.RedPacketBean;

import java.util.List;

/**
 * <b>类名称：    RedPacketAdapter             <br/>
 * <b>类描述：                        <br/>
 * <b>创建人：    Lans               <br/>
 * <b>创建时间：  2018/3/2 12:00     <br/>
 * <b>修改人：                        <br/>
 * <b>修改时间：                      <br/>
 * <b>修改备注：                      <br/>
 *
 * @version 1.0.0 <br/>
 */
public class RedPacketAdapter extends BaseQuickAdapter<RedPacketBean, BaseViewHolder> {
    private int type;

    public RedPacketAdapter(@Nullable List<RedPacketBean> data) {
        super(R.layout.fragment_red_packet_list_item, data);
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, RedPacketBean item) {
        helper.setText(R.id.date, item.getEnd_date() + "前使用")
                .addOnClickListener(R.id.use);
        TextView cash = helper.getView(R.id.cash);//"¥" + item.getHbje());
        if (type == 1) {
            cash.setText(item.getAdd_rate_format());
        } else {
            cash.setText("¥" + item.getHbje());
        }
    }
}
